<template>
  <el-config-provider :locale="appStore.locale" :size="size">
    <router-view />
  </el-config-provider>
</template>

<script setup lang="ts">
import { computed, nextTick, onMounted, watch } from 'vue'
import { useRouter, useRoute } from 'vue-router'
const route = useRoute()
const router = useRouter()
import { handleThemeStyle } from '@/utils/theme'

import useAppStore from '@/store/modules/app'
import useSettingsStore from '@/store/modules/settings'
import { SettingTypeEnum } from '@/enums/SettingTypeEnum'
const settingsStore = useSettingsStore()
const appStore = useAppStore()
const size = computed(() => appStore.size as any)

onMounted(() => {
  nextTick(() => {
    // 初始化主题样式
    handleThemeStyle(useSettingsStore().theme)
  })
})

//处量跳转到首页导航显示的问题
watch(
  () => router.currentRoute.value,
  (newValue: any) => {
    if (newValue.path === '/index') {
      settingsStore.changeSetting({ key: SettingTypeEnum.COLLAPSE, value: false })
      settingsStore.setMinSubmenu(false)
    }
  },
  { immediate: false }
)
</script>
